import React, { Component } from 'react'

export default class List extends Component {
    constructor(props){
        super(props);
        this.state = {
            list:[{id:1},{id:2},{id:3},{id:4}]
        }

    }
  render() {
    return (
      <div>
        {this.state.list.map(item=>{
            return  <div key={item.id} onClick={()=>{

                this.props.history.push("/detail/"+item.id);

            }} style={{border:"1px solid red"}}>{item.id}</div>
        })}
        <hr/>
        {this.state.list.map(item=>{
            return  <div key={item.id} onClick={()=>{

                this.props.history.push({
                    pathname:"detail2",
                    state:{
                        id:item.id
                    }
                });

            }} style={{border:"1px solid red"}}>{item.id}</div>
        })}
      </div>
    )
  }
}
